package com.foreknow.demo13;

import java.io.*;

/**
 * @author shkstart
 * @create 2021-08-02 15:16
 */
public class BufferedDemo {
    public static void main(String[] args) {
        //创建一个节点流
        try {
            FileReader fr=new FileReader("IODemo.java");
            //创建一个BufferReader处理流
            BufferedReader br=new BufferedReader(fr);

            FileWriter fw=new FileWriter("new_IODemo.java");
            BufferedWriter bw=new BufferedWriter(fw);

            //读取源文件中的一行
            String s = br.readLine();
            while (s!=null){
                bw.write(s);
                bw.newLine();
                //读取下一行
               s=br.readLine();
            }
            //释放资源
            br.close();
            bw.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
